package com.tiantian.quanminxiu.presenter;

import com.tiantian.quanminxiu.utils.UserData;
import com.tiantian.quanminxiu.view.DialogGiftRecordView;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.Iterator;


/**
 * Created by admin on 2016/9/14.
 */
public class DialogGiftRecordPresent implements Presenter<DialogGiftRecordView> {

    private DialogGiftRecordView dialogGiftRecordView;

    @Override
    public void attachView(DialogGiftRecordView view) {
        this.dialogGiftRecordView = view;
    }

    @Override
    public void detachView() {
        this.dialogGiftRecordView = null;
    }

    public void getGiftRecord(){
        JSONArray temArray = new JSONArray();
        Iterator iter = UserData.Current.AnchorGiftList.iterator();
        while(iter.hasNext()) {
            temArray.put((JSONObject) iter.next());
        }
        JSONArray giftArray = new JSONArray();
        for (int i=temArray.length()-1;i>=0;i--){
            giftArray.put(temArray.optJSONObject(i));
        }
        dialogGiftRecordView.getGiftRecord(giftArray);
    }
}
